<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24" type="flex" align="middle">
          <a-col flex="450px">
            <a-form-item label="">
              <a-input-group compact>
              <a-select v-model="queryParam.searchField" @change="changeForceUpdate" :dropdownMatchSelectWidth="false">
                <a-select-option value="userName"> 姓名 </a-select-option>
                <a-select-option value="userNameId"> 账号 </a-select-option>
                <a-select-option value="deptName"> 部门名 </a-select-option>
              </a-select>
              <a-input-search
                style="width: 78%"
                v-model="queryParam.keyword"
                @search="searchQuery"
                placeholder="请按照关键字进行搜索"
              />
              </a-input-group>
            </a-form-item>
          </a-col>
          <a-col flex="auto">
            <span class="flex-btn-line">
              <a-button type="primary" @click="showSearchForm=true" icon="search">高级查询</a-button>
              <a-button type="primary" icon="download" @click="handlePostExportXls('个人项目业绩报表')">导出</a-button>
              <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>

      <a-modal
      :visible="showSearchForm"
      width="70vw"
      :bodyStyle="{ padding: '10px' }"
      title="高级查询"
      @ok="handleToSearch"
      @cancel="showSearchForm=false"
    >
      <a-form-model ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item label="姓名">
              <a-input v-model="queryParam.userName" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="账号">
              <a-input v-model="queryParam.userNameId" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="部门名">
              <a-input v-model="queryParam.deptName" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-modal>

    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        :rowKey="rowKey"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,onSelectAll:onSelectAll,columnWidth:1}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetails(record)">明细</a>
        </span>

      </a-table>
    </div>
    <LuckSheetPaste :title="'程项目绩点与得分批量导入'" ref="luckSheetPaste" :columnsExcel="columnsExcel"  @handleOkExcel="handleOkExcel" ></LuckSheetPaste>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListSearchMixin'
  import JInput from '@/components/jeecg/JInput'
  import LuckSheetPaste from '@/components/excelPaste/LuckSheetPaste'
  import { httpAction, getAction,postAction } from '@/api/manage'
  import {codeInfoList} from '@/api/codeInfo'
  export default {
    name: 'QueryPersonBear',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
   
      JInput,
      LuckSheetPaste
    },
    data () {
      return {

        /* 勾选导出参数 */
        rowKey:'rank',
        busType:'QueryPersonBear',
        /* 排序参数 */
        isorter:{
          column: null,
          order: 'desc',
        },
        description: '个人承担项目报表',
        toggleSearchStatus:true,
        // 表头
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   width:60,
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   }
          // },
          // {
          //   title:'排名',
          //   width: 5,
          //   align:"center",
          //   dataIndex: 'rank'
          // },
          {
            title:'姓名',
            align:"center",
            dataIndex: 'userName'
          },
            {
            title:'账号',
            align:"center",
            dataIndex: 'userNameId'
          },
          {
            title:'部门',
            align:"center",
            dataIndex: 'deptName'
          },
           {
            title:'担任项目经理',
            align:"center",
            dataIndex: 'managerProject',
            sorter: (a, b) => a.managerProject - b.managerProject,
          },
         
          {
            title:'担任项目成员',
            align:"center",
            dataIndex: 'memberProject',
            sorter: (a, b) => a.memberProject - b.memberProject,
          },
           {
            title:'项目合计',
            align:"center",
            dataIndex: 'totalProject',
            sorter: (a, b) => a.totalProject - b.totalProject,
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/reportCenter/queryPersonBear",
          exportXlsUrl: "/reportCenter/exportXlsPersonBear",
        },
        dictOptions:{},
        superFieldList:[],
        columnsExcel:[
           {
            title:'导入表头',
            align:"center",
            dataIndex: 'projectLevel'
          },
         
        ],
        gradePointTypeList:[],
        showSearchForm:false,
        labelCol: { span: 8 },
        wrapperCol: { span: 15 },
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
       
    },
    methods: {
      handleDetails(record){
        // window.open('/projectReport/queryPersonPointDetails?userNameId='+record.userNameId, '_blank')
        this.$router.push({path:'/reportWork/queryPersonPointDetails',query:{userNameId: record.userNameId}})
      },
      importExcelDataBtn(){
        this.$refs.luckSheetPaste.showModalExcel();
      },
      handleOkExcel(data,excelVm){
        excelVm.handleErroMsg('操作异常:'+res.message);
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        
        this.superFieldList = fieldList
      },
      handleToSearch(){
        this.showSearchForm=false;
        this.searchQuery();
      },
      searchReset(){
        this.queryParam={};
        this.queryParam.searchField='userName';
        this.handleToSearch();
      }
    },
    mounted() {
      this.queryParam.searchField='userName'
    },
  }
</script>
<style lang="less" scoped>
  @import '~@assets/less/common.less';
  @import '~@assets/less/hte-main.less';
</style>